/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;

/**
 *
 * @author Jojo
 */
public class CustomHtmlBrowser extends JEditorPane {
    
    public CustomHtmlBrowser(){
        super();
        this.setEditable(false);
    }
    
    public void setHtmlFile(String htmlSourceAsString, File pathToHtmlFile){
        HTMLDocument doc = (HTMLDocument)this.getDocument();
        try {
            doc.setBase(pathToHtmlFile.toURI().toURL());
            System.out.println("Dir:"+pathToHtmlFile);
        } catch (MalformedURLException ex) {
            Logger.getLogger(CustomHtmlBrowser.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.setText(htmlSourceAsString);
    }
    
}
